﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Cms/Admin.Master" AutoEventWireup="true"
    CodeBehind="AlbumMan.aspx.cs" Inherits="Aij1.Cms.AlbumMan" %>

<%@ Register Assembly="DevExpress.Web.v13.1, Version=13.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxGridView" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v13.1, Version=13.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v13.1, Version=13.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Data.Linq" TagPrefix="cc1" %>
<%@ Register Assembly="DevExpress.Xpo.v13.1.Web, Version=13.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Xpo" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v13.1, Version=13.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxTreeView" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxTreeList.v13.1, Version=13.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxTreeList" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.v13.1, Version=13.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dx1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .style1 { width: 100%; }
        .templateTable { border-collapse: collapse; width: 100%; }
        .templateTable td { border: solid 1px #C2D4DA; padding: 3px; }
        .templateTable td.value { font-weight: bold; }
    </style>
    <script type="text/javascript">
        var catId;
        function tree_NodeClick(s, e) {
            catId = e.nodeKey;
            document.getElementById("hdnCategoryId").value = catId;
            grid.PerformCallback();
        }

        function btnNew_Click(s, e) {
            window.open('Album.aspx?CatId=' + tree.GetFocusedNodeKey());
        }

        function btnSetTop_Click(s, e) {
            if (confirm("确认置顶?")) {
                grid.PerformCallback('settop:0');
            }
        }

        function btnCancelTop_Click(s, e) {
            if (confirm("确认取消置顶?")) {
                grid.PerformCallback('canceltop:0');
            }
        }

        function editAlbum(albumId) {
            window.open('Album.aspx?Id=' + albumId);
        }

        function btnDelete_Click(s, e) {
            var selkeys = grid.GetSelectedKeysOnPage().join(',');
            if (selkeys.length > 0 && confirm("确认删除?")) {
                grid.PerformCallback('del:' + selkeys);
            }
        }

        function btnSetTop_Click(s, e) {
            var selkeys = grid.GetSelectedKeysOnPage().join(',');
            if (selkeys.length > 0 && confirm("确认置顶?")) {
                grid.PerformCallback('settop:' + selkeys);
            }
        }

        function btnCancelTop_Click(s, e) {
            var selkeys = grid.GetSelectedKeysOnPage().join(',');
            if (selkeys.length > 0 && confirm("确认取消置顶?")) {
                grid.PerformCallback('canceltop:' + selkeys);
            }
        }

        function grid_CustomButtonClick(s, e) {
            switch (e.buttonID) {
                case "cmdSetTop":
                    grid.PerformCallback('settop:' + s.GetRowKey(e.visibleIndex));
                    break;
                case "cmdCancelTop":
                    grid.PerformCallback('canceltop:' + s.GetRowKey(e.visibleIndex));
                    break;
                default:
                    window.open('Album.aspx?Id=' + s.GetRowKey(e.visibleIndex));
                    break;
            }
        }
    </script>
</asp:Content>
<asp:Content ID="CT2" ContentPlaceHolderID="PH" runat="server">
    <input type="hidden" value="" id="hdnCategoryId" name="CategoryId" />
    <table class="style1">
        <tr>
            <td>
            </td>
            <td>
                <table class="style1">
                    <tr>
                        <td width="120">
                            <dx:ASPxButton ID="btnNew" runat="server" Text="新增" AutoPostBack="False">
                                <ClientSideEvents Click="btnNew_Click" />
                            </dx:ASPxButton>
                        </td>
                        <td width="120">
                            <dx:ASPxButton ID="btnDelete" runat="server" Text="批量删除" AutoPostBack="False" ClientInstanceName="btnDelete">
                                <ClientSideEvents Click="btnDelete_Click" />
                            </dx:ASPxButton>
                        </td>
                        <td width="120">
                            <dx:ASPxButton ID="btnSetTop" runat="server" Text="置顶" AutoPostBack="False" 
                                ClientInstanceName="btnSetTop">
                                <ClientSideEvents Click="btnSetTop_Click" />
                            </dx:ASPxButton>
                        </td>
                        <td>
                            <dx:ASPxButton ID="btnCancelTop" runat="server" Text="取消置顶" AutoPostBack="False"
                                ClientInstanceName="btnCancelTop">
                                <ClientSideEvents Click="btnCancelTop_Click" />
                            </dx:ASPxButton>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr valign="top">
            <td width="160">
                <dx:ASPxTreeList ID="TL" runat="server" AutoGenerateColumns="False" ClientInstanceName="tree"
                    Width="100%" KeyFieldName="Oid" ParentFieldName="ParentId!Key" DataSourceID="XpoDataSource2">
                    <Columns>
                        <dx:TreeListTextColumn Caption="栏目" FieldName="Title" VisibleIndex="0">
                        </dx:TreeListTextColumn>
                    </Columns>
                    <ClientSideEvents NodeClick="tree_NodeClick" />
                    <SettingsBehavior AllowFocusedNode="True" AllowSort="False" FocusNodeOnLoad="False"
                        AutoExpandAllNodes="true" />
                    <ClientSideEvents NodeClick="tree_NodeClick"></ClientSideEvents>
                </dx:ASPxTreeList>
            </td>
            <td>
                <dx:ASPxGridView ID="GV" runat="server" AutoGenerateColumns="False" DataSourceID="XpoDataSource1"
                    KeyFieldName="Oid" Width="100%" ClientInstanceName="grid" Caption="相册管理" OnCustomCallback="ASPxGridView1_CustomCallback"
                    OnRowValidating="ASPxGridView1_RowValidating" OnHtmlRowPrepared="ASPxGridView1_HtmlRowPrepared"
                    PreviewFieldName="Intro">
                    <ClientSideEvents CustomButtonClick="grid_CustomButtonClick" />
                    <Columns>
                        <dx:GridViewCommandColumn ShowSelectCheckbox="True" VisibleIndex="0" Width="30px">
                            <CellStyle HorizontalAlign="Center">
                            </CellStyle>
                            <HeaderTemplate>
                                <dx:ASPxCheckBox ID="SelectAllCheckBox" runat="server" ToolTip="全选/全不选本页所有行" ClientSideEvents-CheckedChanged="function(s, e) { grid.SelectAllRowsOnPage(s.GetChecked()); }" />
                            </HeaderTemplate>
                            <HeaderStyle HorizontalAlign="Center" />
                            <CellStyle HorizontalAlign="Center" />
                        </dx:GridViewCommandColumn>
                        <dx:GridViewDataTextColumn FieldName="Oid" ReadOnly="True" VisibleIndex="1" Caption="编号"
                            Width="40px">
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewDataComboBoxColumn Caption="栏目" FieldName="CategoryId!Key" Name="colCatName"
                            VisibleIndex="2" Width="60px">
                            <PropertiesComboBox DataSourceID="XpoDataSource2" TextField="Title" ValueField="Oid">
                            </PropertiesComboBox>
                            <CellStyle HorizontalAlign="Center">
                            </CellStyle>
                        </dx:GridViewDataComboBoxColumn>
                        <dx:GridViewDataTextColumn FieldName="Title" VisibleIndex="4" Caption="标题" Width="30%">
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewDataDateColumn FieldName="DisplayTime" VisibleIndex="5" Caption="发表时间"
                            Width="110px">
                            <PropertiesDateEdit DisplayFormatString="yyyy-MM-dd HH:mm" EditFormat="Custom" EditFormatString="yyyy-MM-dd HH:mm">
                            </PropertiesDateEdit>
                            <CellStyle HorizontalAlign="Center">
                            </CellStyle>
                        </dx:GridViewDataDateColumn>
                        <dx:GridViewDataTextColumn FieldName="Author" VisibleIndex="6" Caption="作者" Width="80px">
                        </dx:GridViewDataTextColumn>
                        <dx:GridViewDataComboBoxColumn Caption="状态" FieldName="Status" Name="colStatus" VisibleIndex="7"
                            Width="80px">
                            <CellStyle HorizontalAlign="Center">
                            </CellStyle>
                            <PropertiesComboBox ValueType="System.Int32">
                            </PropertiesComboBox>
                        </dx:GridViewDataComboBoxColumn>
                        <dx:GridViewCommandColumn Caption="操作" VisibleIndex="8" Width="90px">
                            <DeleteButton Visible="True" Text="删除">
                            </DeleteButton>
                            <EditButton Visible="True" Text="编辑">
                            </EditButton>
                            <CancelButton Text="取消">
                            </CancelButton>
                            <UpdateButton Text="修改">
                            </UpdateButton>
                            <ClearFilterButton Visible="True">
                            </ClearFilterButton>
                            <CustomButtons>
                                <dx:GridViewCommandColumnCustomButton ID="cmdEditArticle" Text="打开">
                                </dx:GridViewCommandColumnCustomButton>
<%--                                <dx:GridViewCommandColumnCustomButton ID="cmdSetTop" Text="置顶">
                                </dx:GridViewCommandColumnCustomButton>
                                <dx:GridViewCommandColumnCustomButton ID="cmdCancelTop" Text="取消">
                                </dx:GridViewCommandColumnCustomButton>
--%>                            </CustomButtons>
                        </dx:GridViewCommandColumn>
                    </Columns>
                    <SettingsEditing Mode="Inline" />
                    <Settings ShowPreview="True" />
                    <Templates>
                        <PreviewRow>
                            <table width="100%">
                                <tr valign="top">
                                    <td width="100">
                                        <a href='../Gallery.aspx?Id=<%#Eval("Oid") %>' target="_blank">
                                            <img src='<%# ImageUrl(Eval("SamplePhotoId!Key")) %>' alt='<%#Eval("Title") %>' style="border: 0px;
                                                width: 100px; height: 70px;" />
                                        </a>
                                    </td>
                                    <td>
                                        <%# GetIntro( Eval("Intro")) %>
                                    </td>
                                </tr>
                            </table>
                        </PreviewRow>
                    </Templates>
                    <SettingsBehavior EnableRowHotTrack="True"></SettingsBehavior>
                    <SettingsPager PageSize="20">
                    </SettingsPager>
                </dx:ASPxGridView>
            </td>
        </tr>
    </table>
    <dx:XpoDataSource ID="XpoDataSource1" runat="server" ServerMode="True" TypeName="Aij1.Model.A_Article"
        DefaultSorting="SetTopTime DESC, DisplayTime DESC" Criteria="AType=1">
    </dx:XpoDataSource>
    <dx:XpoDataSource ID="XpoDataSource2" runat="server" TypeName="Aij1.Model.A_Category"
        DefaultSorting="OrderId" Criteria="AType=1 OR AType=0">
    </dx:XpoDataSource>
</asp:Content>
